package part1;

/**
 * Java5Ex1
 *   Example of an enhanced for loop
 * @author tony
 *
 */
public class Java5Ex1 {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		final int SIZE = 1000;
		float[] far= new float[ SIZE ];
		/*
		 * Regular for loop
		 */
		for (int i=0; i<SIZE; i++){
			far[i] = SIZE * (float) Math.random();
		}
		
		/*
		 * Enhanced for loop
		 */
		float sum = 0;
		for ( float f : far)
			sum += f;
		
		System.out.println( "Sum of " + SIZE + " elements in far array is " + sum );
	}

}
